export default {
  data() {
    return {
      isIOS: false,//ios是否审核
      visitCount: 0, //浏览记录
      token: '',
      id: '', //用户id
      name: '', //用户名
      AccountType: 0, //0会员（不亮）1合伙人2服务商
      percent: 0 * 4, //进度
      price: 0, //我的收益金额
      title: '我的',
      perList: {},
      //我的订单
      typeMenu: [{
        path: '/pages_order/buy_order/buy_order?index=0',
        imgSrc: 'iconcheliangdingdan',
        text: '车辆订单'
      },
      {
        path: '/pages_order/buy_order/buy_order?swiper=1',
        imgSrc: 'iconweibaodingdan',
        text: '维保订单'
      },
      {
        path: '/pages_order/buy_order/buy_order?index=1',
        imgSrc: 'iconxunjiadingdan',
        text: '我的询价'
      },
      {
        path: '/pages_order/buy_order/buy_order?index=2',
        imgSrc: 'iconchepindingdan',
        text: '我的预约'
      },
      ],
      //77合伙人
      partner: [{
        path: '/pages_order/promotion_order/promotion_order',
        imgSrc: 'https://files.yzsheng.com/client/me/img/tuiguangdingdan.png',
        text: '我的推广订单',
        id: 0
      },
      {
        path: '/pages_userModule/myFriend/myFriend',
        imgSrc: 'https://files.yzsheng.com/client/me/img/wodehaoyou.png',
        text: '我的好友',
        id: 1
      },
      {
        path: '/pages_common/pages_me/settlement/settlement',
        imgSrc: 'https://files.yzsheng.com/client/me/img/shengqing@2x.png',
        text: '服务商申请',
        id: 2
      },
      ],

      //服务商推广订单
      extension: [{
        id: 1,
        path: '#',
        imgSrc: 'iconjinxing',
        text: '进行中'
      },
      {
        id: 2,
        path: '#',
        imgSrc: 'icondaishangchuan',
        text: '待上传发票'
      },
      {
        id: 3,
        path: '#',
        imgSrc: 'icondaishenhe2',
        text: '待审核'
      },
      {
        id: 4,
        path: '#',
        imgSrc: 'icondaijiesuan',
        text: '待结算'
      },
      {
        id: 5,
        path: '#',
        imgSrc: 'iconyijiesuan',
        text: '已结算'
      },
      {
        id: 6,
        path: '#',
        imgSrc: 'iconyishixiao',
        text: '已失效'
      },
      ],

      show: false,
      shareInfo: {} //邀请
    }
  },
  watch: {

  },
  onShow() {
    this.token = uni.getStorageSync('token')
    uni.getStorage({
      key: 'Ztc_C_USER_INFO',
      success: data => {

        this.name = data.data.trueName
        this.id = data.data.id
        //获取权限信息
        // this.AccountType = data.data.account_Type

      }
    })
    if (this.token) {
      this.getMyInfo()
      this.getVisitCarCount()
      this.isCard()
    } else {
      this.shareInfo = {}
      this.AccountType = ''
      this.visitCount = 0
      // this.shareInfo.myCarCount = 0
    }

  },
  computed: {

  },
  created() {
    this.iOSBool()
  },
  methods: {
    async iOSBool(){
      const res = await this.$api.me.iOSBool()
      let system = uni.getSystemInfoSync() // 获取系统信息
      if (system.platform === 'ios') {
        this.isIOS = res.data
      }
    },
    async isCard() {
      try {
        const res = await this.$api.me.checkIDCardVerify()
        this.isRz = res.data
      } catch (e) {
        //TODO handle the exception
      }
    },
    //我的爱车列表
    async getVisitCarCount() {
      try {
        let data = {
          'type': 0,
          'app_type': 1
        }
        const res = await this.$api.me.getVisitCarCount(data)
        this.visitCount = res.data
      } catch (e) {

      }
    },
    goInfo() {
      if (this.token === '') {
        this.$u.toast('请登录！')
        this.$u.debounce(this.login, 1000)
        return false
      }
      if (this.shareInfo.account_Type === 2) {
        uni.navigateTo({
          url: '/pages_userModule/serviceInformation/serviceInformation'
        })
      } else {
        uni.navigateTo({
          url: '/pages_userModule/personalInformation/personalInformation'
        })
      }

    },
    preview() {
      this.show = true
    },
    //个人信息
    async getMyInfo() {
      try {
        const res = await this.$api.me.getMyInfo()
        this.shareInfo = res.data
        this.AccountType = res.data.account_Type
        if (res.data.account_Type === 2) {
          this.getMyServiceInfo()
        }
        //判断邀请人数是否超过25人
        if (res.data.share > 25) {
          this.percent = 25 * 4
        } else {
          this.percent = res.data.share * 4
        }
      } catch (err) {

      }
    },
    //服务商
    async getMyServiceInfo() {
      try {
        const res = await this.$api.me.getMyServiceInfo()
        this.perList = res.data

      } catch (err) {

      }
    },
    //我的好友
    goFriends() {
      uni.navigateTo({
        url: '/pages_userModule/myFriendbuss/myFriendbuss'
      })
    },
    goSet(url) {
      uni.navigateTo({
        url: url
      })
    },
    //77合伙人icon
    goPartner(url, id) {

      if (this.token === '') {
        this.$u.toast('请登录！')
        this.$u.debounce(this.login, 1000)
        return false
      } else if (id === 2) {
        if (!this.isRz) {
          this.$refs.uToast.show({
            title: '请实名认证',
            url: '/pages_commodity/idCarsAuthentication/idCarsAuthentication?typeid=110'
          })
        }else{
          uni.navigateTo({
					  url: url
          })
        }
      } else {
        uni.navigateTo({
          url: url
        })
      }
    },
    goSetting(){
      uni.navigateTo({
        url: '/pages_system/set_up/set_up'
      })
    },
    //页面跳转
    goPage(url) {
      if (url === '#') {
        this.$u.toast('功能未开发')
      } else {
        if (this.token === '') {
          this.$u.toast('请登录！')
          this.$u.debounce(this.login, 1000)
          return false
        }
        if (url === '/pages_userModule/myCoupon/index') {
          uni.getStorage({
            key: 'Ztc_C_USER_INFO',
            success: data => {
              uni.navigateTo({
                url: url + '?mobile=' + data.data.mobile
              })
            }
          })
        } else {
          uni.navigateTo({
            url: url
          })
        }
      }
    },
    goOrder(id) {
      uni.navigateTo({
        url: '/pages_order/promotion_order/promotion_order?tabId=' + id
      })
    },
    login() {
      uni.setStorage({
        key: 'launchFlag',
        data: false,
      })
      uni.navigateTo({
        url: '/pages_logins/login/login'
      })
    },

    // 跳转到分享海报列表页
    goPostersPage() {
      uni.navigateTo({
        url: '/pages_common/pages_me/marketing/marketing'
      })
    }
  }
}
